﻿using System;
using System . Collections . Generic;
using System . Linq;
using System . Text;
using System . Threading . Tasks;
using System . Xml . Linq;
using WenceyWang . RichMan4L . Players;

namespace WenceyWang . RichMan4L . Maps . Buildings
{
	public class SmallHouse : SmallBuilding
	{
		public long MoneyCostWhenCrossed { get; set; }


		public override bool EasyToDestroy { get { return true; } }

		//Todo:完善价格机制
		public override long MaintenanceFee { get { return 1000; } }

		public override void StartDay ( Calendars . GameDate nextDate )
		{
			if ( disposedValue )
			{
				throw new ObjectDisposedException ( $"{nameof ( SmallHouse )} at {X},{Y}" );
			}
			Owner?.PayForBuilding ( this , MaintenanceFee );
			base . StartDay ( nextDate );
		}
		                 
		public override void Stay ( Player player )
		{
			if ( player != Owner )
			{
				if ( player . IsFreeOfCharge ( ) )
				{

				}
				else
				{
					if ( Owner . IsBlockGetCharge ( ) )
					{

					}
					else
					{
						player . PayForCross ( Position , MoneyCostWhenCrossed );
						Owner . GetFromArea ( Position , player , MoneyCostWhenCrossed );
					}
				}
			}
			base . Stay ( player );
		}

		public override void EndToday ( )
		{

		}

		public SmallHouse ( ) : base ( )
		{

		}
	}
}
